import axios from "../common/configHttp";
import fileGet from "axios";
const fileGets = fileGet.create({
  baseURL: window.CONFIG.url,
  timeout: 600000, // 请求超时
});
fileGets.interceptors.response.use(
  function(response) {
    // Do something with response data
    if (response.data.code === 200) {
      return response.data;
    } else {
      return Promise.reject({
        msg: response.data.msg,
        data: response.data,
      });
    }
  },
  function(error) {
    // Do something with response error
    return Promise.reject({
      msg: "网络错误",
      err: error,
    });
  }
);
//归档任务管理
export function getInfo(data) {
  return fileGets.post("collect/archiveTaskManagementController/access", data);
}
export function getOut(data) {
  return fileGets.post("collect/archiveTaskManagementController/back", data);
}
export function getArchiveTaskByName(data) {
  return axios.post(
    "collect/archiveTaskManagementController/getArchiveTaskByName",
    data
  );
}
export function filterData(params) {
  return axios.get("collect/archiveTaskManagementController/filterData", {
    params: params,
  });
}
// 获取所有标签
export function getAllTarget(data) {
  return axios.post(
    "collect/archiveTaskManagementController/getAllTarget",
    data
  );
}
//外部数据录入
export function getDataList(data) {
  return axios.post("collect/file/list", data);
}
//文件上传
export function fileUpload(fileSource, fileType, data) {
  return fileGets.post(
    `collect/file/upload?fileSource=${fileSource}&fileType=${fileType}`,
    data
  );
}
//文件预览
export function getUrl(data) {
  return axios.get(`collect/file/getUrl/${data.id}`);
}
//文件删除
export function getDel(data) {
  return fileGets.delete(`collect/file/delete`, {
    data: data,
  });
}
//外部数据置标
export function fileLableList(data) {
  return axios.post(`collect/tLabelInfo/fileLableList`, data);
}
// 数据置标 标签
export function getLabel(params) {
  return axios.get(`collect/tLabelInfo/getLabel`, { params: params });
}
//批量提交数据
export function submit(data) {
  return fileGets.post(`collect/file/submit`, data);
}
// 外部数据保存
export function save(data) {
  return fileGets.post(`collect/file/update`, data);
}

// 获取详情页的desc
export function getUpdateData(data) {
  return fileGets.get(
    `/collect/file/getUpdateData?id=${data.id}&type=${data.type}`
  );
}

// 外部数据保存
export function updateOCRInfo(data) {
  return fileGets.post(`collect/file/updateOCRInfo`, data);
}
// ocr识别
export function ocr(data) {
  return fileGets.get(`collect/file/OCRTextRecognition?imageId=${data.dataId}`);
}
// ocr内容
export function getOCRInfo(data) {
  return fileGets.get(`collect/file/getOCRInfo?dataId=${data.dataId}`);
}
//审核
export function approval(data) {
  return fileGets.post(`collect/tDataAudit/approval`, data);
}
//标准规范列表
export function fileList(data) {
  return axios.post(`collect/fileInfo/fileInfoList`, data);
}
//标准规范列表文件预览
export function getInfoUrl(data) {
  return axios.get(`collect/fileInfo/getInfoUrl/${data.id}`);
}
//标准规范列表上传
export function BzfileUpload(creator, fileRemark, fileType, data) {
  return fileGets.post(
    `collect/fileInfo/uploadInfo?creator=${creator}&fileRemark=${fileRemark}&fileType=${fileType}`,
    data
  );
}

//整编库审核
export function Tapproval(data) {
  return fileGets.post(`collect/tprojectfile/approval`, data);
}
// 文件整编
export function TfileLableList(data) {
  return axios.post(`collect/projectReorganize/fileLableList`, data);
}
// 数据置标 标签
export function TgetLabel(params) {
  return axios.get(`collect/projectReorganize/getLabel`, { params: params });
}

//内容识别
export function ContentList(data) {
  return axios.post(`collect/Content/list`, data);
}

//上传界面接口
export function ContentSelectList(data) {
  return axios.post(`collect/Content/selectList`, data);
}
//文件上传1
export function ContentuploadInfo(fileCategory, data) {
  return fileGets.post(
    `collect/Content/uploadInfo?fileCategory=${fileCategory}`,
    data
  );
}
// 文件审核
export function ContentselectAll(data) {
  return axios.post(`collect/Content/selectAll`, data);
}
//内容识别审核通过
export function ContentInto(data) {
  return fileGets.post(`collect/Content/into`, data);
}
//内容识别审核退回
export function ContentBack(data) {
  return fileGets.post(`collect/Content/back`, data);
}
//内容识别删除
export function ContentDelete(data) {
  return fileGets.delete(`collect/Content/delete`, {
    data: data,
  });
}
//内容识别提交数据
export function ContentSave(data) {
  return fileGets.post(`collect/Content/save`, data);
}
// 文本展示 下载
export function fileSave(data) {
  return axios.post(`collect/Content/fileSave`, data, {
    responseType: "arraybuffer",
  });
}

// 通过fileid获取文件名称
export function getFileNames(data) {
  return fileGets.post(`collect/file/getFileNames`, data)
}